using EfSample.Model.Ef.Mappings.Strategies;

namespace EfSample.Model.Ef.Mappings
{
    public class HeroMapping : EntityMappingBase<Hero>
    {
        public HeroMapping(IMappingStrategy<string> tableNameMappingStrategy)
        {
            Map<Hero>(hero => hero.Requires(ColumnNameMappingStrategy.Value.To("IsSuperHero")).HasValue(false)).ToTable(tableNameMappingStrategy.To("Hero"));
            Map<SuperHero>(hero => hero.Requires(ColumnNameMappingStrategy.Value.To("IsSuperHero")).HasValue(true)).ToTable(tableNameMappingStrategy.To("Hero"));
            Property(e => e.Id).HasColumnName(ColumnNameMappingStrategy.Value.To("Id"));
            Property(e => e.Name).HasColumnName(ColumnNameMappingStrategy.Value.To("Name"));
            //Property(e => e.IsSuperHero).HasColumnName(ColumnNameMappingStrategy.Value.To("IsSuperHero"));
            //Property(e => e.Race).HasColumnName(AddUnderscoresBetweenWordsThenToLowerMappingStrategy.Value.To("Race"));
            HasRequired(h => h.Race).WithMany().Map(
                config => config.MapKey(ColumnNameMappingStrategy.Value.To("RaceId")));
        }
    }
}